<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>Utility Functions and Definitions</title>
<link href="tabs.css" rel="stylesheet" type="text/css" />
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="alias.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="alias.js"></script>

<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>


<script type="text/javascript">
  jQuery(document).ready(function () {
    if(gref){ // Number all _img and _table classes
      gref();
    }
  });
</script>

</head>
<body>
<div id="top"><!-- do not remove this div! -->

<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">nRF51822 BLE SDK
   
   </div>
   
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.5 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="annotated.html"><span>Data&#160;Structures</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
  initNavTree('group__ble__sdk__lib__util.html','');
</script>
<div id="doc-content">
<div class="header">
  <div class="summary">
<a href="#nested-classes">Data Structures</a> &#124;
<a href="#define-members">Defines</a> &#124;
<a href="#typedef-members">Typedefs</a> &#124;
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">Utility Functions and Definitions</div>  </div>
<div class="ingroups"><a class="el" href="group__ble__sdk__lib.html">Bluetooth Libraries</a></div></div>
<div class="contents">

<p>Various types and definitions available to all applications.  
<a href="#details">More...</a></p>
<table class="memberdecls">
<tr><td colspan="2"><h2><a name="nested-classes"></a>
Data Structures</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">struct &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structuint8__array__t.html">uint8_array_t</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Byte array type.  <a href="structuint8__array__t.html#details">More...</a><br/></td></tr>
<tr><td colspan="2"><h2><a name="define-members"></a>
Defines</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ga36d525cf4d116b2fe4ecc00222b256f1"></a><!-- doxytag: member="ble_sdk_lib_util::PACKED" ref="ga36d525cf4d116b2fe4ecc00222b256f1" args="" -->
#define&#160;</td><td class="memItemRight" valign="bottom"><b>PACKED</b>&#160;&#160;&#160;__packed</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__ble__sdk__lib__util.html#ga6259b9f2ea4ab48312b1836c71f484bb">GPIO_PIN_CONFIG</a>(PIN_NO, IO_OUTPUT, IO_PULL, IO_DRIVE, IO_SENSE)&#160;&#160;&#160;_GPIO_PIN_CONFIG(PIN_NO, IO_OUTPUT, IO_PULL, IO_DRIVE, IO_SENSE)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Macro to configure an I/O.  <a href="#ga6259b9f2ea4ab48312b1836c71f484bb"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__ble__sdk__lib__util.html#ga3f8d3d1b629cf9a61a86886059987e6a">GPIO_LED_CONFIG</a>(PIN_NO)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Configure a PIN to be used as a LED.  <a href="#ga3f8d3d1b629cf9a61a86886059987e6a"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__ble__sdk__lib__util.html#ga5f313d1d9c2c322ca6b265f597ab7c7d">GPIO_DEBUG_PIN_CONFIG</a>(PIN_NO)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Configure a PIN to be used as a debug pin (e.g. to be monitored using a logic analyzer).  <a href="#ga5f313d1d9c2c322ca6b265f597ab7c7d"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__ble__sdk__lib__util.html#gaf4e57e59f98b21778ea8f231423816fd">GPIOTE_BUTTON_CONFIG</a>(PIN_NO)&#160;&#160;&#160;_GPIOTE_BUTTON_CONFIG(PIN_NO)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Configure a PIN to be used as a push button.  <a href="#gaf4e57e59f98b21778ea8f231423816fd"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__ble__sdk__lib__util.html#ga61149a977f6ebdaeb8bdeed626dd9392">CRITICAL_REGION_ENTER</a>()</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Macro for entering a critical region.  <a href="#ga61149a977f6ebdaeb8bdeed626dd9392"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__ble__sdk__lib__util.html#ga854878240b628e978f760f75aca4e1cc">CRITICAL_REGION_EXIT</a>()</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Macro for leaving a critical region.  <a href="#ga854878240b628e978f760f75aca4e1cc"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__ble__sdk__lib__util.html#ga25e8110559dbc9665dfb9485be8ac60f">ROUNDED_DIV</a>(A, B)&#160;&#160;&#160;(((A) + ((B) / 2)) / (B))</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Perform rounded integer division (as opposed to truncating the result).  <a href="#ga25e8110559dbc9665dfb9485be8ac60f"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__ble__sdk__lib__util.html#ga7aaa817cfd7ed354f09db5675ffe1427">CEIL_DIV</a>(A, B)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Perform integer division, making sure the result is rounded up.  <a href="#ga7aaa817cfd7ed354f09db5675ffe1427"></a><br/></td></tr>
<tr><td colspan="2"><h2><a name="typedef-members"></a>
Typedefs</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="gaa6f104ea023a4a6a56ef05f30b0cfdc3"></a><!-- doxytag: member="ble_sdk_lib_util::uint16_le_t" ref="gaa6f104ea023a4a6a56ef05f30b0cfdc3" args="[2]" -->
typedef uint8_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__ble__sdk__lib__util.html#gaa6f104ea023a4a6a56ef05f30b0cfdc3">uint16_le_t</a> [2]</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">type for holding an encoded (i.e. little endian) 16 bit unsigned integer. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ga634aa3136e273c2a368023ce97e73f01"></a><!-- doxytag: member="ble_sdk_lib_util::uint32_le_t" ref="ga634aa3136e273c2a368023ce97e73f01" args="[4]" -->
typedef uint8_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__ble__sdk__lib__util.html#ga634aa3136e273c2a368023ce97e73f01">uint32_le_t</a> [4]</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">type for holding an encoded (i.e. little endian) 32 bit unsigned integer. <br/></td></tr>
<tr><td colspan="2"><h2><a name="func-members"></a>
Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">static __INLINE uint8_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__ble__sdk__lib__util.html#gab58c28346b89382397aa7a716bf9a178">uint16_encode</a> (uint16_t value, uint8_t *p_encoded_data)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Inline function for encoding a uint16 value.  <a href="#gab58c28346b89382397aa7a716bf9a178"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">static __INLINE uint8_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__ble__sdk__lib__util.html#gad960286275534b81d75fbeba2d52aec9">uint32_encode</a> (uint32_t value, uint8_t *p_encoded_data)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Inline function for encoding a uint32 value.  <a href="#gad960286275534b81d75fbeba2d52aec9"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">static __INLINE uint16_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__ble__sdk__lib__util.html#gaf30655fd762a9debe0b499db3a9451f7">uint16_decode</a> (const uint8_t *p_encoded_data)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Inline function for decoding a uint16 value.  <a href="#gaf30655fd762a9debe0b499db3a9451f7"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">static __INLINE uint32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__ble__sdk__lib__util.html#gaa8eaa6f05cd43462e58a24e54c0ddacd">uint32_decode</a> (const uint8_t *p_encoded_data)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Inline function for decoding a uint32 value.  <a href="#gaa8eaa6f05cd43462e58a24e54c0ddacd"></a><br/></td></tr>
</table>
<hr/><a name="details" id="details"></a><h2>Detailed Description</h2>
<p>Various types and definitions available to all applications. </p>
<hr/><h2>Define Documentation</h2>
<a class="anchor" id="ga6259b9f2ea4ab48312b1836c71f484bb"></a><!-- doxytag: member="ble_sdk_util.h::GPIO_PIN_CONFIG" ref="ga6259b9f2ea4ab48312b1836c71f484bb" args="(PIN_NO, IO_OUTPUT, IO_PULL, IO_DRIVE, IO_SENSE)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define GPIO_PIN_CONFIG</td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">PIN_NO, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">IO_OUTPUT, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">IO_PULL, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">IO_DRIVE, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">IO_SENSE&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td>&#160;&#160;&#160;_GPIO_PIN_CONFIG(PIN_NO, IO_OUTPUT, IO_PULL, IO_DRIVE, IO_SENSE)</td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Macro to configure an I/O. </p>
<p>This macro configures a given I/O to input or output with pullup/buffer configuration.</p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">PIN_NO</td><td>I/O pin to configure. </td></tr>
    <tr><td class="paramname">IO_OUTPUT</td><td>Indicate if the I/O is to be set as an output. </td></tr>
    <tr><td class="paramname">IO_PULL</td><td>Pull resistor. </td></tr>
    <tr><td class="paramname">IO_DRIVE</td><td>Buffer configuration. </td></tr>
    <tr><td class="paramname">IO_SENSE</td><td>Pin sensing mechanism. </td></tr>
  </table>
  </dd>
</dl>

<p>Definition at line <a class="el" href="ble__sdk__util_8h_source.html#l00065">65</a> of file <a class="el" href="ble__sdk__util_8h_source.html">ble_sdk_util.h</a>.</p>

</div>
</div>
<a class="anchor" id="ga3f8d3d1b629cf9a61a86886059987e6a"></a><!-- doxytag: member="ble_sdk_util.h::GPIO_LED_CONFIG" ref="ga3f8d3d1b629cf9a61a86886059987e6a" args="(PIN_NO)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define GPIO_LED_CONFIG</td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">PIN_NO</td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<b>Value:</b><div class="fragment"><pre class="fragment"><span class="keywordflow">do</span>                                                \
    {                                                 \
        GPIO_PIN_CONFIG(PIN_NO,                       \
                        GPIO_PIN_CNF_DIR_Output,      \
                        GPIO_PIN_CNF_PULL_Disabled,   \
                        GPIO_PIN_CNF_DRIVE_S0S1,      \
                        GPIO_PIN_CNF_SENSE_Disabled); \
    } <span class="keywordflow">while</span> (0)
</pre></div>
<p>Configure a PIN to be used as a LED. </p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">PIN_NO</td><td>Input pin to configure. </td></tr>
  </table>
  </dd>
</dl>

<p>Definition at line <a class="el" href="ble__sdk__util_8h_source.html#l00072">72</a> of file <a class="el" href="ble__sdk__util_8h_source.html">ble_sdk_util.h</a>.</p>

</div>
</div>
<a class="anchor" id="ga5f313d1d9c2c322ca6b265f597ab7c7d"></a><!-- doxytag: member="ble_sdk_util.h::GPIO_DEBUG_PIN_CONFIG" ref="ga5f313d1d9c2c322ca6b265f597ab7c7d" args="(PIN_NO)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define GPIO_DEBUG_PIN_CONFIG</td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">PIN_NO</td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<b>Value:</b><div class="fragment"><pre class="fragment"><span class="keywordflow">do</span>                                              \
    {                                               \
        GPIO_PIN_CONFIG(PIN_NO,                     \
                      GPIO_PIN_CNF_DIR_Output,      \
                      GPIO_PIN_CNF_PULL_Disabled,   \
                      GPIO_PIN_CNF_DRIVE_S0S1,      \
                      GPIO_PIN_CNF_SENSE_Disabled); \
    } <span class="keywordflow">while</span> (0)
</pre></div>
<p>Configure a PIN to be used as a debug pin (e.g. to be monitored using a logic analyzer). </p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">PIN_NO</td><td>Input pin to configure. </td></tr>
  </table>
  </dd>
</dl>

<p>Definition at line <a class="el" href="ble__sdk__util_8h_source.html#l00086">86</a> of file <a class="el" href="ble__sdk__util_8h_source.html">ble_sdk_util.h</a>.</p>

</div>
</div>
<a class="anchor" id="gaf4e57e59f98b21778ea8f231423816fd"></a><!-- doxytag: member="ble_sdk_util.h::GPIOTE_BUTTON_CONFIG" ref="gaf4e57e59f98b21778ea8f231423816fd" args="(PIN_NO)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define GPIOTE_BUTTON_CONFIG</td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">PIN_NO</td><td>)</td>
          <td>&#160;&#160;&#160;_GPIOTE_BUTTON_CONFIG(PIN_NO)</td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Configure a PIN to be used as a push button. </p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">PIN_NO</td><td>Input pin to configure. </td></tr>
  </table>
  </dd>
</dl>

<p>Definition at line <a class="el" href="ble__sdk__util_8h_source.html#l00109">109</a> of file <a class="el" href="ble__sdk__util_8h_source.html">ble_sdk_util.h</a>.</p>

</div>
</div>
<a class="anchor" id="ga61149a977f6ebdaeb8bdeed626dd9392"></a><!-- doxytag: member="ble_sdk_util.h::CRITICAL_REGION_ENTER" ref="ga61149a977f6ebdaeb8bdeed626dd9392" args="()" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define CRITICAL_REGION_ENTER</td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<b>Value:</b><div class="fragment"><pre class="fragment">{                                                                                   \
        uint8_t IS_NESTED_CRITICAL_REGION;                                              \
        uint32_t ERR_CODE = <a class="code" href="group__nrf__soc__api.html#ga45b358c92b51248f9e55e1d99756136b" title="Enters critical region.">nrf_nvic_critical_region_enter</a>(&amp;IS_NESTED_CRITICAL_REGION); \
        if (ERR_CODE != <a class="code" href="group__nrf__error.html#ga7e6367efeaac363d8cf024940b4ec123" title="Successful command.">NRF_SUCCESS</a>)                                                    \
        {                                                                               \
            ASSERT(<span class="keyword">false</span>);                                                              \
        }
</pre></div>
<p>Macro for entering a critical region. </p>

<p>Definition at line <a class="el" href="ble__sdk__util_8h_source.html#l00112">112</a> of file <a class="el" href="ble__sdk__util_8h_source.html">ble_sdk_util.h</a>.</p>

</div>
</div>
<a class="anchor" id="ga854878240b628e978f760f75aca4e1cc"></a><!-- doxytag: member="ble_sdk_util.h::CRITICAL_REGION_EXIT" ref="ga854878240b628e978f760f75aca4e1cc" args="()" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define CRITICAL_REGION_EXIT</td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<b>Value:</b><div class="fragment"><pre class="fragment">ERR_CODE = <a class="code" href="group__nrf__soc__api.html#ga476819b5a0f3d7c0a378d11c5ee88650" title="Exit critical region.">nrf_nvic_critical_region_exit</a>(IS_NESTED_CRITICAL_REGION);            \
        if (ERR_CODE != <a class="code" href="group__nrf__error.html#ga7e6367efeaac363d8cf024940b4ec123" title="Successful command.">NRF_SUCCESS</a>)                                                    \
        {                                                                               \
            ASSERT(<span class="keyword">false</span>);                                                              \
        }                                                                               \
    }
</pre></div>
<p>Macro for leaving a critical region. </p>

<p>Definition at line <a class="el" href="ble__sdk__util_8h_source.html#l00122">122</a> of file <a class="el" href="ble__sdk__util_8h_source.html">ble_sdk_util.h</a>.</p>

</div>
</div>
<a class="anchor" id="ga25e8110559dbc9665dfb9485be8ac60f"></a><!-- doxytag: member="ble_sdk_util.h::ROUNDED_DIV" ref="ga25e8110559dbc9665dfb9485be8ac60f" args="(A, B)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define ROUNDED_DIV</td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">A, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">B&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td>&#160;&#160;&#160;(((A) + ((B) / 2)) / (B))</td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Perform rounded integer division (as opposed to truncating the result). </p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">A</td><td>Numerator. </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">B</td><td>Denominator. </td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>Rounded (integer) result of dividing A by B. </dd></dl>

<p>Definition at line <a class="el" href="ble__sdk__util_8h_source.html#l00136">136</a> of file <a class="el" href="ble__sdk__util_8h_source.html">ble_sdk_util.h</a>.</p>

</div>
</div>
<a class="anchor" id="ga7aaa817cfd7ed354f09db5675ffe1427"></a><!-- doxytag: member="ble_sdk_util.h::CEIL_DIV" ref="ga7aaa817cfd7ed354f09db5675ffe1427" args="(A, B)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define CEIL_DIV</td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">A, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">B&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<b>Value:</b><div class="fragment"><pre class="fragment"><span class="comment">/*lint -save -e573 */</span>   \
    ((((A) - 1) / (B)) + 1) \
</pre></div>
<p>Perform integer division, making sure the result is rounded up. </p>
<p>One typical use for this is to compute the number of objects with size B is needed to hold A number of bytes.</p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">A</td><td>Numerator. </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">B</td><td>Denominator. </td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>Integer result of dividing A by B, rounded up. </dd></dl>

<p>Definition at line <a class="el" href="ble__sdk__util_8h_source.html#l00147">147</a> of file <a class="el" href="ble__sdk__util_8h_source.html">ble_sdk_util.h</a>.</p>

</div>
</div>
<hr/><h2>Function Documentation</h2>
<a class="anchor" id="gab58c28346b89382397aa7a716bf9a178"></a><!-- doxytag: member="ble_sdk_util.h::uint16_encode" ref="gab58c28346b89382397aa7a716bf9a178" args="(uint16_t value, uint8_t *p_encoded_data)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">static __INLINE uint8_t uint16_encode </td>
          <td>(</td>
          <td class="paramtype">uint16_t&#160;</td>
          <td class="paramname"><em>value</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t *&#160;</td>
          <td class="paramname"><em>p_encoded_data</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td><code> [static]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Inline function for encoding a uint16 value. </p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">value</td><td>Value to be encoded. </td></tr>
    <tr><td class="paramdir">[out]</td><td class="paramname">p_encoded_data</td><td>Buffer where the encoded data is to be written. </td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>Number of bytes written. </dd></dl>

<p>Definition at line <a class="el" href="ble__sdk__util_8h_source.html#l00158">158</a> of file <a class="el" href="ble__sdk__util_8h_source.html">ble_sdk_util.h</a>.</p>

</div>
</div>
<a class="anchor" id="gad960286275534b81d75fbeba2d52aec9"></a><!-- doxytag: member="ble_sdk_util.h::uint32_encode" ref="gad960286275534b81d75fbeba2d52aec9" args="(uint32_t value, uint8_t *p_encoded_data)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">static __INLINE uint8_t uint32_encode </td>
          <td>(</td>
          <td class="paramtype">uint32_t&#160;</td>
          <td class="paramname"><em>value</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t *&#160;</td>
          <td class="paramname"><em>p_encoded_data</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td><code> [static]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Inline function for encoding a uint32 value. </p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">value</td><td>Value to be encoded. </td></tr>
    <tr><td class="paramdir">[out]</td><td class="paramname">p_encoded_data</td><td>Buffer where the encoded data is to be written. </td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>Number of bytes written. </dd></dl>

<p>Definition at line <a class="el" href="ble__sdk__util_8h_source.html#l00170">170</a> of file <a class="el" href="ble__sdk__util_8h_source.html">ble_sdk_util.h</a>.</p>

</div>
</div>
<a class="anchor" id="gaf30655fd762a9debe0b499db3a9451f7"></a><!-- doxytag: member="ble_sdk_util.h::uint16_decode" ref="gaf30655fd762a9debe0b499db3a9451f7" args="(const uint8_t *p_encoded_data)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">static __INLINE uint16_t uint16_decode </td>
          <td>(</td>
          <td class="paramtype">const uint8_t *&#160;</td>
          <td class="paramname"><em>p_encoded_data</em></td><td>)</td>
          <td><code> [static]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Inline function for decoding a uint16 value. </p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">p_encoded_data</td><td>Buffer where the encoded data is stored. </td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>Decoded value. </dd></dl>

<p>Definition at line <a class="el" href="ble__sdk__util_8h_source.html#l00181">181</a> of file <a class="el" href="ble__sdk__util_8h_source.html">ble_sdk_util.h</a>.</p>

</div>
</div>
<a class="anchor" id="gaa8eaa6f05cd43462e58a24e54c0ddacd"></a><!-- doxytag: member="ble_sdk_util.h::uint32_decode" ref="gaa8eaa6f05cd43462e58a24e54c0ddacd" args="(const uint8_t *p_encoded_data)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">static __INLINE uint32_t uint32_decode </td>
          <td>(</td>
          <td class="paramtype">const uint8_t *&#160;</td>
          <td class="paramname"><em>p_encoded_data</em></td><td>)</td>
          <td><code> [static]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Inline function for decoding a uint32 value. </p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">p_encoded_data</td><td>Buffer where the encoded data is stored. </td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>Decoded value. </dd></dl>

<p>Definition at line <a class="el" href="ble__sdk__util_8h_source.html#l00191">191</a> of file <a class="el" href="ble__sdk__util_8h_source.html">ble_sdk_util.h</a>.</p>

</div>
</div>
</div>
</div>
  <div id="nav-path" class="navpath">
    <ul>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Data Structures</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark">&#160;</span>Defines</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>


    <li class="footer">
      Copyright &copy 2006-2011 <a href="http://www.nordicsemi.no" style="text-decoration:none">Nordic Semiconductor</a>.
      All Rights Reserved.
      <a href="disclaimer.html">Disclaimer</a>
    </li>
   </ul>
 </div>


</body>
</html>
